package com.typy.www.tpay.ui.prt;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ScrollView;

import com.typy.www.tpay.R;
import com.typy.www.tpay.base.PtrBaseContent;
import com.typy.www.tpay.util.Logutil;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 13799 on 2018/6/16.
 */

public abstract class PtrScrollContent extends PtrBaseContent {

    ViewHolder holder;

    private View mContentView;


    public PtrScrollContent(Context context, View contentView) {
        super(context);
        mContentView = contentView;
        initView();
    }
    public PtrScrollContent(Context context, int layoutResid) {
        super(context);
        LayoutInflater inflater = LayoutInflater.from(context);
        mContentView = inflater.inflate(layoutResid, null);
        initView();
    }
    @Override
    protected int getLayoutResId() {
        return R.layout.swipe_scoll;
    }

    private void initView() {
        holder=new ViewHolder(mView);
        holder.svRoot.addView(mContentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    }
    public void setBackgroundResource(int resid) {
        if (resid > 0)
            holder.svRoot.setBackgroundResource(resid);
    }
    public ScrollView getScollView(){
        return holder.svRoot;
    }

    @Override
    protected void loadMoreData() {
    }

    public View getContentView() {
        return mContentView;
    }
    static class ViewHolder {
        @BindView(R.id.sv_root)
        ScrollView svRoot;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
